﻿using System;
using System.Collections;
using UnityEngine;

// Token: 0x02000157 RID: 343
[DisallowMultipleComponent]
[AddComponentMenu("RVP/C#/Vehicle Controllers/Vehicle Debug", 3)]
public class VehicleDebug : MonoBehaviour
{
	// Token: 0x06000632 RID: 1586 RVA: 0x000346A8 File Offset: 0x000328A8
	private void Update()
	{
		if (Input.GetKeyDown(KeyCode.LeftControl))
		{
			base.StartCoroutine(this.ResetRotation());
		}
		if (CenterOrigin.WorldToVirtual(base.transform.position).y < this.fallLimit)
		{
			base.StartCoroutine(this.ResetPosition());
		}
	}

	// Token: 0x06000633 RID: 1587 RVA: 0x00034704 File Offset: 0x00032904
	private IEnumerator ResetRotation()
	{
		if (base.GetComponent<VehicleDamage>())
		{
			base.GetComponent<VehicleDamage>().Repair();
		}
		yield return new WaitForFixedUpdate();
		base.transform.eulerAngles = new Vector3(0f, base.transform.eulerAngles.y, 0f);
		base.transform.Translate(Vector3.up, Space.World);
		base.GetComponent<Rigidbody>().velocity = Vector3.zero;
		base.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
		yield break;
	}

	// Token: 0x06000634 RID: 1588 RVA: 0x00034720 File Offset: 0x00032920
	private IEnumerator ResetPosition()
	{
		if (base.GetComponent<VehicleDamage>())
		{
			base.GetComponent<VehicleDamage>().Repair();
		}
		base.transform.position = this.spawnPos;
		yield return new WaitForFixedUpdate();
		base.transform.rotation = Quaternion.LookRotation(this.spawnRot, GlobalControl.worldUpDir);
		base.GetComponent<Rigidbody>().velocity = Vector3.zero;
		base.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
		yield break;
	}

	// Token: 0x040009B9 RID: 2489
	public Vector3 spawnPos;

	// Token: 0x040009BA RID: 2490
	public Vector3 spawnRot;

	// Token: 0x040009BB RID: 2491
	[Tooltip("Y position below which the vehicle will be reset")]
	private float fallLimit = -1000f;
}
